/**
 * Copyright 2018-2019 jianggujin (www.jianggujin.com).
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jianggujin.modulelink.config;

import java.util.HashSet;
import java.util.Set;

import com.jianggujin.modulelink.util.JAssert;

/**
 * SpringBoot模块配置
 * 
 * @author jianggujin
 *
 */
public class JSpringBootModuleConfig extends JModuleConfig implements JSpringBootModuleConfigAdapter {

    /**
     * SpringBoot source
     */
    private Set<String> sources;

    public JSpringBootModuleConfig(String name) {
        super(name);
    }

    public JSpringBootModuleConfig(JModuleConfig moduleConfig) {
        super(moduleConfig.getModuleName());
        this.setDescription(moduleConfig.getDescription());
        this.setModuleUrls(moduleConfig.getModuleUrls());
        this.setScanPackages(moduleConfig.getScanPackages());
        this.setExclusionActions(moduleConfig.getExclusionActions());
    }

    /**
     * SpringBoot source
     * 
     * @return SpringBoot source
     */
    @Override
    public Set<String> getSources() {
        return sources;
    }

    /**
     * 设置SpringBoot source
     * 
     * @param sources SpringBoot source
     */
    public void setSources(Set<String> sources) {
        this.sources = sources;
    }

    /**
     * 添加SpringBoot source
     * 
     * @param source SpringBoot source
     * @return {@link JSpringBootModuleConfig}
     */
    public JSpringBootModuleConfigAdapter addSource(String source) {
        JAssert.checkNotNull(source, "source must not be null");
        if (this.sources == null) {
            this.sources = new HashSet<String>();
        }
        this.sources.add(source);
        return this;
    }
}
